From: cl349@firebug.cl.cam.ac.uk Date: Tue, 13 Sep 2005 21:29:28 +0000 (+0000) Subject: Perform xenbus operations in shutdown_handler in a transaction. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16806^2~25 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=49917db5e9842a569854d34cabf8436285fdde69;p=xen.git Perform xenbus operations in shutdown_handler in a transaction. Signed-off-by: Christian Limpach --- diff --git a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c index b6608cef49..12c7610e90 100644 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c @@ -320,20 +320,28 @@ static void __shutdown_handler(void *unused) static void shutdown_handler(struct xenbus_watch *watch, const char *node) { static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL); - char *str; + int err; + again: + err = xenbus_transaction_start("control"); + if (err) + return; str = (char *)xenbus_read("control", "shutdown", NULL); - /* Ignore read errors. */ - if (IS_ERR(str)) - return; - if (strlen(str) == 0) { - kfree(str); - return; + /* Ignore read errors and empty reads. */ + if (XENBUS_IS_ERR_READ(str)) { + xenbus_transaction_end(1); + return; } xenbus_write("control", "shutdown", "", O_CREAT); + err = xenbus_transaction_end(0); + if (err == -ETIMEDOUT) { + kfree(str); + goto again; + } + if (strcmp(str, "poweroff") == 0) shutting_down = SHUTDOWN_POWEROFF; else if (strcmp(str, "reboot") == 0)